home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
176-200
/
scopedisk180
/
arexxtutorial
/
listenv
/
listenv.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-03-19
|
2KB
|
114 lines
/* ListEnv.rexx */
/* Written by Don Meyer (Stormgate Software).
* BIX: donmeyer
* GEnie: D.MEYER
* Plink: STORMGATE
*
* This program released into the Public Domain.
*/
/* Modifications by Jeremy Farrance (ETC Software).
* Plink: JEREMY
*
* This program remains in the Public Domain.
*
* Bananas
*/
/* Ver. Date Who Notes
* ---- --------- --- -----------------------------
* 0.0 12-Feb-89 DTM Creation
* 0.1 19-Mar-89 DTM Accept a command line env var name.
*
* 0.2 17-Apr-89 JRF General improvements, fixed ENV names
* with ' ' spaces, added '?' Usage:,
* added opensupport(), now checks if
* ENV: assignment exists and added
* a files listed count, others...
*/
signal on BREAK_C
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then
say 'added rexxsupport.library'
else do;
say 'support library not available'
exit 10
end
end
if ~showlist('A','ENV') then do
say 'ENV: not assigned.'
exit 10
end
arg filename
if filename == "?" then do
say 'Usage: ListEnv [Environment variable name]'
exit 0
end
if length(filename) = 1 & datatype(filename,'U') then pattern = filename
if filename ~= "" & pattern = 'PATTERN' then do
call got_one(filename)
exit 0
end
files = showdir( "ENV:", "File", ":" )
count = 0
do forever
parse upper var files name ':' files
if name == '' then leave
if right(name, 5) == ".INFO" then iterate
if pattern ~= 'PATTERN' & left(name,1) ~= pattern then iterate
count = count + got_one(name)
end
if count > 0 then say count' files'
else say 'No environment variables found'
exit 0
got_one: procedure
arg name
if ~open( src, "ENV:" || name, "Read" ) then do
say "** Unable to access 'ENV:" || name || "' **"
return(0)
end
value = readln( src )
equals = readch( src, 1 )
if ~eof( src ) then value = value || '1B'x || "[33m ...<more>" || '1B'x || "[31m"
if length(value) < 50 then equals = " = "
else do
equals = '1B'x || "[32m =" || '1B'x || "[31m" || '0A'x || " "
if length(value) > 69 then
value = space(left(value,69),0) || '1B'x || "[32m..." || '1B'x || "[31m"
end
say left(name,20) || equals || '"' || value || '"'
call close(src)
return(1)
break_c:
say "*** Control-C recieved. Stopped by user. ***"
exit 5